Skip to content

Fix schema generation for $ref with sibling description (OpenAPI 3.1) - #2

Closed
joseegman-idoneea wants to merge 1 commit into
feat/375-openapi-3.1-supportfrom
fix/ref-with-description
Closed

Fix schema generation for $ref with sibling description (OpenAPI 3.1)#2
joseegman-idoneea wants to merge 1 commit into
feat/375-openapi-3.1-supportfrom
fix/ref-with-description

Conversation

@joseegman-idoneea

Copy link
Copy Markdown
Owner

Problema

En OpenAPI 3.1 un $ref puede llevar hermanos como description. Cuando una propiedad combina $ref + description, el generador de schemas rompe y genera un campo con tipo vacío.

Causa

ApiTool.hasRef solo reconocía la referencia si $ref era el primer campo del nodo. Con description antes de $ref, devolvía false y el nodo caía en la rama isBasicType.

Cambios

  • hasRef ahora detecta un $ref de nivel superior con independencia del orden de los campos.
  • Nuevo test de regresión testRefWithDescription (cubre description antes y después de $ref) con sus assets.
  • Bump de versión 6.4.16.4.2 en engine, maven-plugin y gradle-plugin.

Verificación

Suite completa del módulo multiapi-engine: 109 tests, 0 fallos (mvn test).

Closes #1

🤖 Generated with Claude Code

OpenAPI 3.1 / JSON Schema 2020-12 allow sibling keywords (e.g. `description`)
next to `$ref`, and their ordering is not significant. `ApiTool.hasRef` only
treated a node as a reference when `$ref` was the *first* field, so a property
declaring `description` before `$ref` was not recognised as a reference: it fell
through to the basic-type branch and generated a field with an empty type,
breaking generation.

`hasRef` now detects a top-level `$ref` regardless of field ordering. Adds a
regression test (`testRefWithDescription`) covering both orderings.

Bumps version 6.4.1 -> 6.4.2.

Closes #1

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@joseegman-idoneea

Copy link
Copy Markdown
Owner Author

Reemplazado por el PR contra upstream: sngular#381

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant